//
//  SIXFindTableController.m
//  weibo
//
//  Created by   李小云 on 16/5/20.
//  Copyright © 2016年 chuhan. All rights reserved.
//

#import "SIXFindTableController.h"
#import "SIXFieldView.h"
#import "Masonry.h"

@interface SIXFindTableController ()

@end

@implementation SIXFindTableController
static NSString *ID = @"mess";
- (void)viewDidLoad {
    [super viewDidLoad];
    /**
     *  设置导航栏内容
     */
    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
    UILabel *titleLable = [[UILabel alloc]init];
    titleLable.text = @"发现群";
    titleLable.textColor = [UIColor blackColor];
    titleLable.font = [UIFont systemFontOfSize:20];
    [titleLable sizeToFit];
    self.navigationItem.titleView = titleLable;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"新建群" style:UIBarButtonItemStylePlain target:self action:@selector(rigthBtnClick)];
      [self.tableView registerNib:[UINib nibWithNibName:@"SIXFindTableCell" bundle:nil] forCellReuseIdentifier:@"FindCell"];
    
     [self.tableView registerNib:[UINib nibWithNibName:@"headViewCell" bundle:nil] forCellReuseIdentifier:@"headCell"];
    
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    
    // 告诉tableView的估算高度
    self.tableView.estimatedRowHeight = 80;
}

-(void)rigthBtnClick{
    
    
    
}
#pragma mark tableView -代理和数据源方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 4;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 0) {
        return 1;
    }
    
    if (section == 1) {
        
        return 3;
    };
    if (section == 2) {
        
        return 3;
    };
    
    return 50;
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"headCell"];
        
        return cell;
    }
    
    if (indexPath.section == 1) {
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        
        if (cell == nil) {
            
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.textLabel.text = @"我是超人";
            cell.detailTextLabel.text = @"没有数据,怎么办?凉拌呗";
            cell.imageView.image = [UIImage imageNamed:@"message_creategroup_portrait"];
        }
        
        return cell;
    }else{
        
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FindCell"];
        return cell;
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        
        return 100;
    }
    
    return 70;
}
/**
 *  返回组头部文字
 *
 */
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    
    if (section == 1) {
        
        return @"明星人气榜";
    };
    if (section == 2) {
        
        return @"特别推荐";
    };
    
    if (section == 3) {
        
        return @"附近的群";
    };
   
    return nil;
}

@end
